#include <iostream>

#include <cassert>

using namespace std;

class point
{
private:
  int x, y;

public:
  point() : x{0}, y{0} {}
  int getx() { return x; }
};
// 测试初始化问题
class op
{
  int x;
  double y;

public:
  int getx() { return x; }
  double gety() { return y; }
};

// 测试连环构造问题
template <typename T>
class oop
{
  T x;

public:
  oop(T v) { x = v; }
  void print() { cout << "\n"
                      << x << "\n"; }
  operator T() { return x; }
  oop &operator()(T v)
  {
    x = v;
    return *this;
  }
};

class opp
{
  int x;
  double y;

public:
  opp(int a, double b) : x{a}, y{b} {}
  int getx() { return x; }
  double gety() { return y; }
};

class oppp
{
  int x;
  double y;

public:
  oppp(int a) : x{a} {}
  int getx() { return x; }
  double gety() { return y; }
};

int main(int argc, char const *argv[])
{
  point *p;
  // 会自动调用默认构造函数
  p = new point[10];
  cout << p[5].getx() << endl;

  // 不会执行初始化  out: 垃圾值
  // op tt;
  // 会初始化 out: 0 0
  op tt{};
  cout << "\n"
       << tt.getx() << "\n"
       << tt.gety() << "\n";
  // 先构造 oop对象 然后不断调用函数重载  最后进行类型转换
  // 可以生成静态的对象
  int m = oop<int>(2)(3)(5);
  // m.print();
  cout << m << "\n";

  opp *mm;
  // 创建一个对象并初始化
  mm = new opp(2, 3.0);
  cout << mm->getx() << "\n"
       << mm->gety() << "\n";


  oppp pp(3);
  // 垃圾值
  cout << "\n" << pp.gety() << "\n";
  
  return 0;
}
